Level3 = Class.extend({
	init: function(context, images) {
		this.context = context;
		this.image = images;
		this.initEnemyL3 = 3000;
		this.enemyAlive = 0;
	},
	
	initEnemy: function() {
		var self = this;
		
		this.generateRandomEnemies(self);
        this.chooseEnemyInterval = setInterval(function() { 
        	self.generateRandomEnemies(self);
        }, self.initEnemyL3);
	},
	
	generateRandomEnemies: function(self) {
		var self = this;
		
	    var randomNumber = Math.floor(Math.random()*4);
	    this.Shoot = 0;
	    	    	
	    switch (randomNumber) {
		case 0:
			self.enemy31 = new Enemy31(self.context, self.image[4]);		
			self.activEnemyPosition = self.enemy31.initEnemy(self.Shoot);
			self.enemy31.shooterEnemy(true);
			self.enemyAlive = 31;
			break;
		case 1:
			self.enemy32 = new Enemy32(self.context, self.image[2]);
			self.activEnemyPosition = self.enemy32.initEnemy(self.Shoot);
			self.enemy32.shooterEnemy(true);
			self.enemyAlive = 32;
			break;
		case 2:
			self.enemy33 = new Enemy33(self.context, self.image[6])
			self.activEnemyPosition = self.enemy33.initEnemy(self.Shoot);
			self.enemy33.shooterEnemy(true);
			self.enemyAlive = 33;
			break;
		case 3:
			self.enemy34 = new Enemy34(self.context, self.image[0])
			self.activEnemyPosition = self.enemy34.initEnemy(self.Shoot);
			self.enemy34.shooterEnemy(true);
			self.enemyAlive = 34;
			break;
		default:
			break;
	    }
	},
	
	checkedPosition: function(mouseCoordinate) {
		var self = this;
		this.mouseCoordinateX = mouseCoordinate[0];
		this.mouseCoordinateY = mouseCoordinate[1];
       		
        if(this.mouseCoordinateX > self.activEnemyPosition[0] && this.mouseCoordinateX < self.activEnemyPosition[2] &&
        	this.mouseCoordinateY > self.activEnemyPosition[1] && this.mouseCoordinateY < self.activEnemyPosition[3] ){
        
        	this.playerMoney +=100;
            this.playerPoint +=100;
            
            this.Shoot++;
            
            switch (self.enemyAlive) {
			case 31:
				self.enemy31.dyingEnemy(self.Shoot);
                self.enemy31.shooterEnemy(false);
				break;
			case 32:
				self.enemy32.dyingEnemy(self.Shoot);
                self.enemy32.shooterEnemy(false);
				break;
			case 33:
				self.enemy33.dyingEnemy(self.Shoot);
                self.enemy33.shooterEnemy(false);
				break;	
			case 34:
				self.enemy34.dyingEnemy(self.Shoot);
                self.enemy34.shooterEnemy(false);
				break;	
			default:
				break;
			};
			
			if(self.Shoot === 1) {
				setTimeout(function() {
					clearInterval(self.chooseEnemyInterval);   
					self.initEnemy();
				}, 680)
			}
			
          };
  
	}
})